package com.erp.service.customer.Impl;

import com.erp.domain.ErpCustomer;

import com.erp.mapper.customer.ErpCustomerMapper;
import com.erp.service.customer.ErpCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * --- 天道酬勤 ---
 *
 * @author ZhangYuqi
 * @date 2025/9/2
 * @desc
 */
@Service
public class ErpCustomerServiceImpl implements ErpCustomerService {
    @Autowired
    private ErpCustomerMapper erpCustomerMapper;
    @Override
    public List<ErpCustomer> selectCustomerList(ErpCustomer erpCustomer) {
        return erpCustomerMapper.selectCustomerList(erpCustomer);
    }

    @Override
    public int addCustomer(ErpCustomer erpCustomer) {
        return erpCustomerMapper.addCustomer(erpCustomer);
    }

    @Override
    public ErpCustomer selectCustomerById(Long customerId) {
        return erpCustomerMapper.selectCustomerById(customerId);
    }

    @Override
    public int updateCustomer(ErpCustomer erpCustomer) {
        return erpCustomerMapper.updateCustomer(erpCustomer);
    }

    @Override
    public int enableCustomer(Long customerId) {
        return erpCustomerMapper.enableCustomer(customerId);
    }

    @Override
    public int disableCustomer(Long customerId) {
        ErpCustomer customer = new ErpCustomer();
        customer.setCustomerId(customerId);
        customer.setIsActive(2); // 2表示禁用状态
        return erpCustomerMapper.disableCustomer(customerId);
    }

    @Override
    public boolean checkCustomerRelation(Long customerId) {
        return erpCustomerMapper.checkCustomerRelation(customerId) > 0;
    }

}
